<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script type="text/javascript">
     //数字类型的数组，对数组的数据进行排序
     function sortTest(nums,fn){
      for(var i=0;i<nums.length-1;i++){
        for(var j=0;j<nums.length-1-i;j++){
          // if(nums[j]<nums[j+1]){
          if(fn(nums[j],nums[j+1])>0){
            var temp = nums[j];
            nums[j] = nums[j+1];
            nums[j+1] = temp;
          }
        }
      }
      return nums;
     }

     var nums = sortTest(
      [{id:1,name:'zhangsan',age:10,scorce:80},{id:2,name:'lisi',age:15,scorce:70},{id:3,name:'wangwu',age:12,scorce:75}],
      function(n1,n2){
        return n1.scorce-n2.scorce;
      }
    );
     console.log(nums);
  </script>
</head>
<body>
  hello html
</body>
</html>